<?php

namespace app\admin\model;

use think\Model;

class Buser extends Model
{
    // 表名
    protected $name = 'buser';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'status_text',
        'gender_text',
        'qq_friend_text',
        'wecaht_friend_text'
    ];
    

    
    public function getStatusList()
    {
        return ['1' => __('Status 1'),'2' => __('Status 2'),'3' => __('Status 3'),'4' => __('Status 4'),'5' => __('Status 5'),'6' => __('Status 6')];
    }     

    public function getGenderList()
    {
        return ['1' => __('Gender 1'),'2' => __('Gender 2')];
    }     

    public function getQqFriendList()
    {
        return ['1' => __('Qq_friend 1'),'2' => __('Qq_friend 2')];
    }     

    public function getWecahtFriendList()
    {
        return ['1' => __('Wecaht_friend 1'),'2' => __('Wecaht_friend 2')];
    }
    public function getTypeList()
    {
        return ['1' => __('Helist 1'),'2' => __('Helist 2'),'3' => __('Helist 3'),'4' => __('Helist 4')];
    }

    public function getStatusTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getGenderTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
        $list = $this->getGenderList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getQqFriendTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['qq_friend']) ? $data['qq_friend'] : '');
        $list = $this->getQqFriendList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getWecahtFriendTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['wecaht_friend']) ? $data['wecaht_friend'] : '');
        $list = $this->getWecahtFriendList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function company()
    {
        return $this->belongsTo('Company', 'company_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
